package com.gyp.controller.video;

import com.gyp.enums.SystemConfigEnum;
import com.gyp.model.common.Result;
import com.gyp.service.SystemConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "系统配置")
@RestController
@RequestMapping("/config")
@Validated
@RequiredArgsConstructor
public class SystemConfigController {

    private final SystemConfigService systemConfigService;

    @ApiOperation("查看系统配置")
    @GetMapping("/query")
    public Result<Object> getSystemConfig(@ApiParam("配置项") @RequestParam("configCode") SystemConfigEnum configCode){
        return Result.data(systemConfigService.getSystemConfig(configCode));
    }

    @ApiOperation("修改系统配置")
    @GetMapping("/update")
    public Result<String> updateSystemConfig(@ApiParam("配置项") @RequestParam("configCode") SystemConfigEnum configCode,
                                             @ApiParam("配置值") @RequestParam("configValue") String value){
        systemConfigService.updateSystemConfig(configCode,value);
        System.out.println(111);
        System.out.println(111);
        return Result.success("修改系统配置成功");
    }



}
